import SIdentify from "./identify.vue";
export default {
  components: {
    SIdentify,
  },
  data() {
    var checkAccount = (rule, value, callback) => {
      if (!value.trim()) {
        return callback(new Error("请输入账号"));
      } else {
        callback();
      }
    };
    var checkPassword = (rule, value, callback) => {
      if (value.trim() === "") {
        callback(new Error("请输入密码"));
      } else {
        callback();
      }
    };
    // 验证码自定义验证规则
    const validateVerifycode = (rule, value, callback) => {
      console.log(rule, "rule");
      console.log(value, "value");
      let newVal = value.toLowerCase();
      let identifyStr = this.identifyCode.toLowerCase();
      if (newVal === "") {
        callback(new Error("请输入验证码"));
      } else if (newVal !== identifyStr) {
        console.log("validateVerifycode:", value);
        callback(new Error("验证码不正确!"));
      } else {
        callback();
      }
    };
    return {
      isLocked: true,
      checkHuman: "",
      form: {
        account: "",
        password: "",
        requestseq: "",
        verifycode: "",
      },
      src: "",
      loginType: "岗位或企业录入人员登录",
      checked: false,
      identifyCodes:
        "1234567890ABCDEFGHIGKLMNoPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz",
      identifyCode: "",
      rules: {
        account: [
          {
            validator: checkAccount,
            trigger: "blur",
          },
        ],
        password: [
          {
            validator: checkPassword,
            trigger: "blur",
          },
        ],
        verifycode: [
          {
            validator: validateVerifycode,
            required: true,
            trigger: "blur",
          },
        ],
      },
      loginShow: false,
      bgURl: [
        {
          id: "1",
          url: "./assets/img/side1.png",
          path: "/home/dashboard",
        },
        {
          id: "2",
          url: "./assets/img/side2.png",
          path: "/home/socical",
        },
        {
          id: "3",
          url: "./assets/img/side3.png",
          path: "/home/member",
        },
        {
          id: "4",
          url: "./assets/img/side4.png",
          path: "/home/employment",
        },
        {
          id: "5",
          url: "./assets/img/side5.png",
          path: "/home/company",
        },
        {
          id: "6",
          url: "./assets/img/side6.png",
          path: "/home/banner",
        },
        {
          id: "7",
          url: "./assets/img/side7.png",
          path: "/home/newest",
        },
        {
          id: "8",
          url: "./assets/img/side8.png",
          path: "/home/feedback",
        },
        {
          id: "9",
          url: "./assets/img/side9.png",
          path: "/home/invoice",
        },
        {
          id: "10",
          url: "./assets/img/side10.png",
          path: "/home/abnormal",
        },
        {
          id: "11",
          url: "./assets/img/side11.png",
          path: "/home/",
        },
        {
          id: "12",
          url: "./assets/img/side12.png",
          path: "/home/systemManage",
        },
        {
          id: "13",
          url: "./assets/img/side13.png",
          path: "/home/contract",
        },
        {
          id: "14",
          url: "./assets/img/side14.png",
          path: "/home/flexible",
        },
        {
          id: "15",
          url: "./assets/img/side15.png",
          path: "/home/stores",
        },
      ],
    };
  },
  created() {
    this.refreshCode();
  },
  mounted() {
    // 验证码初始化
    this.identifyCode = "";
    this.makeCode(this.identifyCodes, 4);
  },
  methods: {
    gotoHome() {
      console.log(this.loginType);
      if (this.loginType == "岗位或企业录入人员登录") {
        this.$router.push({
          path: "/home/pgentering",
        });
      }
      if (this.loginType == "电话招聘人员登录") {
        this.$telAxios
          .post("/v1/librarian/selectFlexibileUserInfo", {
            accountNumber: this.form.account,
            passWord: this.form.password,
          })
          .then((res) => {
            console.log(res);
            if (res.data.code === 1000) {
              let userinfo = res.data.data;
              userinfo.type = "telRecruit";
              this.checkHuman = userinfo.name;
              userinfo.username = userinfo.name;
              userinfo.account = userinfo.accountNumber;
              delete userinfo.accountNumber;
              // userinfo.identityId = prev + this.form
              // 	.password + next;
              let recruitList = [];
              if (userinfo.grade === "10" || userinfo.grade === "30") {
                recruitList = [
                  {
                    power: "61",
                    powername: "概览",
                    url: "./assets/img/recruit2.png",
                    path: "/home/overviewPage",
                  },
                  {
                    power: "69",
                    powername: "微信公众号后台",
                    url: "./assets/img/recruit2.png",
                    path: "/home/flexbleAccount",
                    tablelist: [],
                  },
                  {
                    power: "41",
                    powername: "电话招聘人员管理",
                    url: "./assets/img/recruit1.png",
                    path: "/home/personnelManage",
                  },
                  {
                    power: "42",
                    powername: "项目管理",
                    url: "./assets/img/recruit2.png",
                    path: "/home/projectManage",
                  },
                ];
                localStorage.setItem("pageTitle", "电话招聘人员管理");
                this.$store.dispatch("setPageTitle", "电话招聘人员管理");
              } else if (userinfo.grade === "20") {
                recruitList = [
                  {
                    power: "43",
                    powername: "招聘信息录入",
                    url: "./assets/img/recruit3.png",
                    path: "/home/materialsManage",
                  },
                  {
                    power: "88",
                    powername: "人才库",
                    url: "./assets/img/recruit2.png",
                    path: "/home/talentpPool",
                  },
                  // {
                  // 	power: "44",
                  // 	powername: "回收处 ",
                  // 	url: "./assets/img/recruit4.png",
                  // 	path: "/home/recyclingOffice"
                  // }
                ];
                localStorage.setItem("pageTitle", "招聘信息录入");
                this.$store.dispatch("setPageTitle", "招聘信息录入");
              }
              userinfo.permisstions = recruitList;
              localStorage.removeItem("userinfo");
              localStorage.setItem("userid", userinfo.userId);
              this.userinfo = userinfo;
              localStorage.setItem("userinfo", JSON.stringify(userinfo));
              localStorage.setItem("checkHuman", this.checkHuman);
              if (localStorage.getItem("currentUserinfo") == null) {
                localStorage.setItem(
                  "currentUserinfo",
                  JSON.stringify(userinfo)
                );
              }

              this.$message({
                message: "登录成功",
                type: "success",
              });
              this.$router.push({
                path: userinfo.permisstions[0].path,
              });
            } else {
              this.$message({
                message: res.data.message,
                type: "warning",
              });
              this.refreshCode();
            }
          });
        this.$router.push({
          path: "/home/materialsManage",
        });
      }
    },
    handleClose() {
      this.loginShow = false;
    },
    submit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          // 提交
          let ajaxData = {};
          // 复制对象复制给ajaxData这个对象
          Object.assign(ajaxData, this.form);
          console.log(ajaxData);
          this.isLocked = true;
          let prev = "",
            next = "";
          for (let i = 0; i < 7; i++) {
            prev +=
              this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
            next +=
              this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
          }
          //后台登录的接口
          this.$axios
            .post("/system/v1/platform/user/login", ajaxData)
            .then((res) => {
              console.log(res);
              this.isLocked = false;
              if (res.data.message === "success.") {
                // 在这里获取到的userinfo就是没有  "2006"的
                let userinfo = res.data.data;
                userinfo.type = "backstage";
                userinfo.identityId = prev + this.form.password + next;
                console.log(userinfo);
                console.log(userinfo.permisstions);

                if (userinfo.permisstions.length > 2) {
                  if (
                    userinfo.permisstions.length > 1 &&
                    userinfo.permisstions[2].power == "3" &&
                    userinfo.permisstions[2].powername == "会员管理"
                  ) {
                    // if (userinfo.permisstions.length > 1 ) {
                    userinfo.permisstions[2].tablelist.push({
                      table: "3003",
                      tablename: "消息推送",
                      buttonlist: [],
                    });
                    userinfo.permisstions[2].tablelist.push({
                      table: "3004",
                      tablename: "收入管理",
                      buttonlist: [],
                    });
                    let contract = {
                      power: "13",
                      powername: "电子合同",
                      tablelist: [
                        {
                          table: "1301",
                          tablename: "电子合同认证",
                          buttonlist: [],
                        },
                        {
                          table: "1302",
                          tablename: "代理人认证",
                          buttonlist: [],
                        },
                        {
                          table: "1303",
                          tablename: "审核人认证",
                          buttonlist: [],
                        },
                      ],
                      url: "./assets/img/side13.png",
                      path: "/home/contract",
                    };
                    let stores = {
                      power: "15",
                      powername: "发才网线下门店",
                      tablelist: [
                        {
                          table: "1501",
                          tablename: "门店列表",
                          buttonlist: [],
                        },
                        {
                          table: "1502",
                          tablename: "门店信息审核",
                          buttonlist: [],
                        },
                        {
                          table: "1503",
                          tablename: "返费管理",
                          buttonlist: [],
                        },
                        {
                          table: "1503",
                          tablename: "公告岗位管理",
                          buttonlist: [],
                        },
                      ],
                      url: "./assets/img/side15.png",
                      path: "/home/stores",
                    };
                    let flexible = {
                      power: "14",
                      powername: "灵活用工",
                      tablelist: [
                        {
                          table: "1401",
                          tablename: "企业需求",
                          buttonlist: [],
                        },
                        {
                          table: "1402",
                          tablename: "报名用户",
                          buttonlist: [],
                        },
                        {
                          table: "1403",
                          tablename: "个体商户认证",
                          buttonlist: [],
                        },
                      ],
                      url: "./assets/img/side14.png",
                      path: "/home/flexible",
                    };

                    let entering = {
                      power: "16",
                      powername: "录入专员",
                      tablelist: [],
                      url: "./assets/img/side14.png",
                      path: "/home/entering",
                    };

                    let pgentering = {
                      power: "17",
                      powername: "企业/岗位录入",
                      tablelist: [],
                      url: "./assets/img/side14.png",
                      path: "/home/pgentering",
                    };

                    let housemanager = {
                      power: "67",
                      powername: "发才网家政专区",
                      tablelist: [],
                      url: "./assets/img/side14.png",
                      path: "/home/housemanager",
                    };
                    let extensionSystem = {
                      power: "67",
                      powername: "推广管理系统",
                      tablelist: [],
                      url: "./assets/img/side14.png",
                      path: "/home/extensionSystem",
                    };
                    let flexbleAccount = {
                      power: "69",
                      powername: "微信公众号后台",
                      url: "./assets/img/recruit2.png",
                      path: "/home/flexbleAccount",
                      tablelist: [],
                    };

                    userinfo.permisstions.splice(2, 0, contract);
                    userinfo.permisstions.splice(4, 0, stores);
                    userinfo.permisstions.splice(5, 0, flexible);
                    userinfo.permisstions.splice(6, 0, housemanager);
                    userinfo.permisstions.splice(8, 0, extensionSystem);
                    userinfo.permisstions.splice(3, 0, flexbleAccount);
                    // userinfo.permisstions.splice(7, 0, pgentering);
                  }
                }

                /* 等级为30的账号权限 */
                if (userinfo.grade == "30") {
                  userinfo.permisstions = [
                    {
                      path: "/home/member",
                      power: "3",
                      powername: "会员管理",
                      tablelist: [
                        {
                          buttonlist: [
                            {
                              button: "300104",
                              buttonname: "会员导出",
                            },
                          ],
                          table: "3001",
                          tablename: "会员列表",
                        },
                      ],
                      url: "./assets/img/side3.png",
                    },
                  ];
                }

                this.checkHuman = userinfo.username;
                for (const key in userinfo.permisstions) {
                  // 获取到 userinfo.permisstions 的0-10的这个  键
                  for (const key1 in this.bgURl) {
                    // 把 this.bgURl [key1] 的id  是不是  ====  userinfo.permisstions  [key] 里面的power
                    if (
                      userinfo.permisstions[key].power === this.bgURl[key1].id
                    ) {
                      // 是的话  就把 其他的也都给   userinfo.permisstions
                      userinfo.permisstions[key].url = this.bgURl[key1].url;
                      userinfo.permisstions[key].path = this.bgURl[key1].path;
                    }
                  }
                }
                console.log(userinfo);
                localStorage.removeItem("userinfo");
                localStorage.setItem("userid", res.data.data.userid);
                localStorage.setItem("department", res.data.data.department);

                localStorage.setItem("telnum", res.data.data.telnum);
                localStorage.setItem("userinfo", JSON.stringify(userinfo));
                localStorage.setItem("checkHuman", this.checkHuman);
                // console.log(localStorage.getItem('userinfo'))
                if (localStorage.getItem("currentUserinfo") == null) {
                  localStorage.setItem(
                    "currentUserinfo",
                    JSON.stringify(userinfo)
                  );
                }
                this.$message({
                  message: "登录成功",
                  type: "success",
                });

                console.log(userinfo.permisstions[0].path);
                if (userinfo.account == "fcwlhyg") {
                  return this.$router.push({
                    // path: "/home/" + userinfo.permisstions[0].path
                    path: "/home/flexibleEmployment/PlatformQualification",
                  });
                }

                if (userinfo.account == "kfgl001") {
                  return this.$router.push({
                    // path: "/home/" + userinfo.permisstions[0].path
                    path: "/home/overviewPage",
                  });
                }

                if (userinfo.account == "kefumanager") {
                  return this.$router.push({
                    // path: "/home/" + userinfo.permisstions[0].path
                    path: "/home/overviewPage",
                  });
                }

                if (userinfo.account == "wechatManager") {
                  return this.$router.push({
                    // path: "/home/" + userinfo.permisstions[0].path
                    path: "/home/wechatManager/PlatformQualification",
                  });
                }
                this.$router.push({
                  // path: "/home/" + userinfo.permisstions[0].path
                  path: userinfo.permisstions[0].path,
                });
                console.log(userinfo.permisstions[0].path);
              } else if (res.data.code == 131) {
                this.$ceshiAxios3
                  .post("/v1/common/inputlogin", ajaxData)
                  .then((res) => {
                    this.$telAxios
                      .post("/v1/librarian/selectFlexibileUserInfo", {
                        accountNumber: this.form.account,
                        passWord: this.form.password,
                      })
                      .then((item) => {
                        if (
                          item.data.message == "登录成功" &&
                          res.data.message == "success."
                        ) {
                          this.loginShow = true;
                          return false;
                        }
                        console.log(item.data.data);
                        console.log(item.data);
                      });
                    let userinfo = res.data.data;
                    if (res.data.code == 1) {
                      res.data.data.permisstions = [];
                      res.data.data.permisstions[0] = "/home/pgentering";
                      userinfo.type = "backstages";
                      localStorage.setItem("userid", res.data.data.userid);
                      localStorage.setItem("telnum", res.data.data.telnum);
                      localStorage.setItem(
                        "userinfo",
                        JSON.stringify(userinfo)
                      );
                      console.log(res.data.data);
                      console.log(res.data.data.permisstions[0]);
                      return this.$router.push({
                        path: res.data.data.permisstions[0],
                      });
                      // this.$message.warning(';;;;;;')
                    } else {
                      this.$telAxios
                        .post("/v1/librarian/selectFlexibileUserInfo", {
                          accountNumber: this.form.account,
                          passWord: this.form.password,
                        })
                        .then((res) => {
                          console.log(res);
                          if (res.data.code === 1000) {
                            let userinfo = res.data.data;
                            userinfo.type = "telRecruit";
                            this.checkHuman = userinfo.name;
                            userinfo.username = userinfo.name;
                            userinfo.account = userinfo.accountNumber;
                            delete userinfo.accountNumber;
                            userinfo.identityId =
                              prev + this.form.password + next;
                            let recruitList = [];
                            if (
                              userinfo.grade === "10" ||
                              userinfo.grade === "30"
                            ) {
                              recruitList = [
                                {
                                  power: "61",
                                  powername: "概览",
                                  url: "./assets/img/recruit2.png",
                                  path: "/home/overviewPage",
                                },
                                {
                                  power: "41",
                                  powername: "电话招聘人员管理",
                                  url: "./assets/img/recruit1.png",
                                  path: "/home/personnelManage",
                                },
                                {
                                  power: "42",
                                  powername: "项目管理",
                                  url: "./assets/img/recruit2.png",
                                  path: "/home/projectManage",
                                },
                              ];
                              localStorage.setItem(
                                "pageTitle",
                                "电话招聘人员管理"
                              );
                              this.$store.dispatch(
                                "setPageTitle",
                                "电话招聘人员管理"
                              );
                            } else if (userinfo.grade === "20") {
                              recruitList = [
                                {
                                  power: "43",
                                  powername: "招聘信息录入",
                                  url: "./assets/img/recruit3.png",
                                  path: "/home/materialsManage",
                                },
                                {
                                  power: "88",
                                  powername: "人才库",
                                  url: "./assets/img/recruit2.png",
                                  path: "/home/talentpPool",
                                },
                                {
                                  power: "98",
                                  powername: "发才网人才库",
                                  url: "./assets/img/recruit2.png",
                                  path: "/home/fcwTelentPool",
                                },

                                // {
                                // 	power: "44",
                                // 	powername: "回收处 ",
                                // 	url: "./assets/img/recruit4.png",
                                // 	path: "/home/recyclingOffice"
                                // }
                              ];
                              localStorage.setItem("pageTitle", "招聘信息录入");
                              this.$store.dispatch(
                                "setPageTitle",
                                "招聘信息录入"
                              );
                            }
                            userinfo.permisstions = recruitList;
                            localStorage.removeItem("userinfo");
                            localStorage.setItem("userid", userinfo.userId);
                            this.userinfo = userinfo;
                            localStorage.setItem(
                              "userinfo",
                              JSON.stringify(userinfo)
                            );
                            localStorage.setItem("checkHuman", this.checkHuman);
                            if (
                              localStorage.getItem("currentUserinfo") == null
                            ) {
                              localStorage.setItem(
                                "currentUserinfo",
                                JSON.stringify(userinfo)
                              );
                            }

                            this.$message({
                              message: "登录成功",
                              type: "success",
                            });
                            this.$router.push({
                              path: userinfo.permisstions[0].path,
                            });
                          } else {
                            this.$message({
                              message: res.data.message,
                              type: "warning",
                            });
                            this.refreshCode();
                          }
                        });
                    }
                  });
              } else {
                this.$message.warning(res.data.message);

                // //家政登录的接口地址
                // this.$axios
                // .$post('https://zjsy.fcw-china.com/housekeeping/Login/selectLogin',ajaxData).then(res => {
                //  console.log(res);
                //  if(res.data.code === 1000){
                //   let userinfo = res.data.data;
                //   userinfo.type = 'housekeep';
                //   this.checkHuman = userinfo.username;
                //   userinfo.identityId = prev + this.form.password + next;
                //   let houseList = [];
                //   if(userinfo.grade === '10' || userinfo.grade === '13'){
                // 	userinfo.position = '总账户';
                // 	userinfo.department = 'CEO';
                // 	houseList = [
                // 		{power: "21", powername: "概览", url: "./assets/img/house1.png", path: "/home/houseIndex"},
                // 		{power: "22", powername: "雇主管理", url: "./assets/img/house2.png", path: "/home/employer"},
                // 		{power: "23", powername: "家政从业者管理", url: "./assets/img/house3.png", path: "/home/practitioner"},
                // 		{power: "24", powername: "岗位招聘管理", url: "./assets/img/house4.png", path: "/home/enterprise"},
                // 		{power: "25", powername: "线下辅导站管理", url: "./assets/img/house5.png", path: "/home/warrant"},
                // 		/* {power: "26", powername: "月子会所管理", url: "./assets/img/house6.png", path: "/home/clubManage"},
                // 		{power: "27", powername: "家政网点管理", url: "./assets/img/house7.png", path: "/home/networkManage"}, */
                // 	]
                //   }else if(userinfo.grade === '11'){
                // 	userinfo.position = userinfo.storesList[0].storesName;
                // 	userinfo.curBranchId = userinfo.storesList[0].storesID;
                // 	this.$store.dispatch("setCurBranchId", userinfo.storesList[0].storesID);
                // 	userinfo.department = '门店负责人';
                // 	houseList = [
                // 	 	{power: "21", powername: "门店概览", url: "./assets/img/house1.png", path: "/home/houseIndex"},
                // 	 	{power: "22", powername: "雇主管理", url: "./assets/img/house2.png", path: "/home/employer"},
                // 	 	{power: "23", powername: "家政从业者管理", url: "./assets/img/house3.png", path: "/home/practitioner"},
                // 	 	{power: "24", powername: "岗位招聘管理", url: "./assets/img/house4.png", path: "/home/enterprise"},
                // 	 	{power: "25", powername: "操作员账户管理", url: "./assets/img/house5.png", path: "/home/warrant"} ,
                // 	]
                //   }else if(userinfo.grade === '12'){
                // 	userinfo.position = userinfo.branchName;
                // 	userinfo.department = '门店管理员';
                // 	houseList = [
                // 	  	{power: "21", powername: "门店概览", url: "./assets/img/house1.png", path: "/home/houseIndex"},
                // 	  	{power: "22", powername: "雇主管理", url: "./assets/img/house2.png", path: "/home/employer"},
                // 	  	{power: "23", powername: "家政从业者管理", url: "./assets/img/house3.png", path: "/home/practitioner"},
                // 	  	{power: "24", powername: "岗位招聘管理", url: "./assets/img/house4.png", path: "/home/enterprise"}
                // 	]
                //   }
                //   userinfo.permisstions = houseList;
                //   localStorage.removeItem('userinfo')
                //   localStorage.setItem(
                //     'userid',
                //     res.data.data.userid
                //   )
                //   localStorage.setItem('userinfo', JSON.stringify(userinfo))
                //   localStorage.setItem(
                //     'checkHuman',
                //     this.checkHuman
                //   )
                //   if (localStorage.getItem('currentUserinfo') == null) {
                //     localStorage.setItem(
                //       'currentUserinfo',
                //       JSON.stringify(userinfo)
                //     )
                //   }

                //   this.$message({
                //     message: '登录成功',
                //     type: 'success'
                //   })
                //   this.$router.push({
                //     path: userinfo.permisstions[0].path
                //   })
                //  }else{
                // 	this.$telAxios.post('/v1/librarian/selectFlexibileUserInfo',{
                // 		accountNumber: this.form.account,
                // 		passWord: this.form.password
                // 	}).then(res => {
                // 		console.log(res);
                // 		if(res.data.code === 1000){
                // 			let userinfo = res.data.data;
                // 			userinfo.type = 'telRecruit';
                // 			this.checkHuman = userinfo.name;
                // 			userinfo.username = userinfo.name;
                // 			userinfo.account = userinfo.accountNumber;
                // 			delete userinfo.accountNumber;
                // 			userinfo.identityId = prev + this.form.password + next;
                // 			let recruitList = [];
                // 			if(userinfo.grade === '10' || userinfo.grade === '30'){
                // 				recruitList = [
                // 					{power: "41", powername: "电话招聘人员管理", url: "./assets/img/recruit1.png", path: "/home/personnelManage"},
                // 					{power: "42", powername: "项目管理", url: "./assets/img/recruit2.png", path: "/home/projectManage"}
                // 				]
                // 				localStorage.setItem('pageTitle','电话招聘人员管理');
                // 				this.$store.dispatch('setPageTitle','电话招聘人员管理');
                // 			}else if(userinfo.grade === '20'){
                // 				recruitList = [
                // 					{power: "43", powername: "电话招聘资料管理", url: "./assets/img/recruit3.png", path: "/home/materialsManage"},
                // 					{power: "44", powername: "回收处 ", url: "./assets/img/recruit4.png", path: "/home/recyclingOffice"}
                // 				]
                // 				localStorage.setItem('pageTitle','电话招聘资料管理');
                // 				this.$store.dispatch('setPageTitle','电话招聘资料管理');
                // 			}
                // 			userinfo.permisstions = recruitList;
                // 			localStorage.removeItem('userinfo');
                // 			localStorage.setItem('userid',userinfo.userId);
                // 			this.userinfo = userinfo;
                // 			localStorage.setItem('userinfo', JSON.stringify(userinfo));
                // 			localStorage.setItem(
                // 			  'checkHuman',
                // 			  this.checkHuman
                // 			)
                // 			if (localStorage.getItem('currentUserinfo') == null) {
                // 			  localStorage.setItem(
                // 			    'currentUserinfo',
                // 			    JSON.stringify(userinfo)
                // 			  )
                // 			}

                // 			this.$message({
                // 			  message: '登录成功',
                // 			  type: 'success'
                // 			})
                // 			this.$router.push({
                // 			  path: userinfo.permisstions[0].path
                // 			})

                // 		}else{
                // 			this.$message({
                // 				message: res.data.message,
                // 				type: 'warning'
                // 			})
                // 			this.refreshCode()
                // 		}
                // 	})

                //  }
                // })
              }
            });
        } else {
          return false;
        }
      });
    },
    // 生成随机数
    randomNum(min, max) {
      return Math.floor(Math.random() * (max - min) + min);
    },
    // 切换验证码
    refreshCode() {
      this.identifyCode = "";
      this.makeCode(this.identifyCodes, 4);
    },
    // 生成四位随机验证码
    makeCode(o, l) {
      for (let i = 0; i < l; i++) {
        this.identifyCode +=
          this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
      }
      console.log(this.identifyCode);
    },
  },
};
